package com.cskaoyan.controller;


import com.cskaoyan.bean.baseresultVO.BaseData;
import com.cskaoyan.bean.baseresultVO.BaseParam;
import com.cskaoyan.bean.baseresultVO.BaseRespVo;
import com.cskaoyan.bean.domain.Collect;
import com.cskaoyan.bean.domain.User;

import com.cskaoyan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author stone
 * @date 2021/11/29 15:11
 */
@RestController
@RequestMapping("admin/")
public class UserController {

    @Autowired
    UserService userService;

    ///admin/user/list?page=1&limit=20&username=user&mobile=110&sort=add_time&order=desc
    @RequestMapping("user/list")
    //public Object list(Integer page,Integer limit,String username,String mobile,String sort,String order) {
    public BaseRespVo list(String username, String mobile,BaseParam param) {
        BaseData data = userService.list(username, mobile,param);
        return BaseRespVo.ok(data);
    }

    @RequestMapping("user/detail")
    public BaseRespVo userDetail(Integer id){
        User data=userService.queryId(id);
        return BaseRespVo.ok(data);


    }


    @RequestMapping("address/list")
    public BaseRespVo addresslist(String name,Integer userId,BaseParam param){
        BaseData data=userService.addresslist(name,userId,param);
        return BaseRespVo.ok(data);
        
    }
    @RequestMapping("collect/list")
    public BaseRespVo collectList( Integer userId,Integer valueId,BaseParam param){
         BaseData data=userService.queryCollects(userId,valueId,param);
         return BaseRespVo.ok(data);

    }
    @RequestMapping("footprint/list")
    public BaseRespVo footprintList(Integer userId,Integer goodsId,BaseParam param){
          BaseData data=userService.queryfootprint(userId,goodsId,param);
          return BaseRespVo.ok(data);

    }
    @RequestMapping("history/list")
    public BaseRespVo historyList(Integer userId, String keyword,BaseParam param){
        BaseData data = userService.queryHistories(userId,keyword,param);
        return BaseRespVo.ok(data);
    }
    @RequestMapping("feedback/list")
    public BaseRespVo feedbackList(String username, Integer id,BaseParam param){
        BaseData data = userService.queryFeedbacks(username,id,param);
        return BaseRespVo.ok(data);
    }

    @PostMapping("user/update")
    public BaseRespVo  updateData(@RequestBody User user){
        userService.updateData(user);
        return BaseRespVo.ok(1);

    }

}
